package cate.game.play.proce.round;


import cate.game.play.fighter.PetFighter;
import cate.game.play.proce.turn.TurnCtx;
import easy.java.dev.note.NoteClass;

import java.util.LinkedList;

@NoteClass("灵宠回合处理器")
public class RoundPetHandler {

    private RoundCtx round;

    public RoundPetHandler(RoundCtx round) {
        this.round = round;
    }

    /**
     * 回合开始
     */
    public void onBegin() {
        LinkedList<PetFighter> pets = new LinkedList<>(round.getTeamVs().getPetsBySpeed());
        while (!pets.isEmpty()) {
            if (round.getTeamVs().isOver()) {
                // 已经分出胜负
                break;
            }
            PetFighter f = pets.removeFirst();
            if (round.index < f.unlockRound) {
                continue;
            }
            TurnCtx turnCtx = new TurnCtx(round, f, null, false);
            //开始行动
            turnCtx.start();
        }
    }
}
